package com.sq.partner.manager.dao.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.sq.partner.manager.dao.FacadeAppInsuredDao;
import com.sq.partner.manager.mybatis.model.FacadeAppInsured;

/**
 * 被保人Dao实现类
 * @author zhouxiuxiu
 *
 */
@Repository
public class FacadeAppInsuredDaoImpl extends BaseDaoImpl implements
        FacadeAppInsuredDao {

    /**
     * 得到一个新的被保人ID
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public String queryNewClientNo() throws SQLException {
        return (String) this.query("queryNewClientNo", "BBR");
    }

    /**
     * 添加被保险人
     * @param param
     * @throws Exception
     */
    @Override
    public void insertFacadeAppInsured(FacadeAppInsured param) throws Exception {
        this.add("insertFacadeAppInsured", param);
    }

    /**
     * 修改被保险人
     * @param facadeAppInsured
     * @throws Exception
     */
    @Override
    public void updateAppInsuredNotNull(FacadeAppInsured facadeAppInsured)
            throws Exception {
        this.update("updateFacadeAppInsuredNotNull", facadeAppInsured);
    }
    
    /**
     * 查询被保险人
     * @param map
     * @return FacadeAppInsured
     * @throws Exception
     */
    @Override
    public FacadeAppInsured selectFacadeAppInsuredByMap(Map<String, String> map)
        throws Exception {
        return (FacadeAppInsured) this.query("queryFacadeAppInsuredByMap", map);
    }
    
    /**
     * 查询被保险人
     * @param map
     * @return FacadeAppInsured
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @Override
    public List<FacadeAppInsured> selectFacadeAppInsuredList(
            Map<String, String> map) throws SQLException {
        return (List<FacadeAppInsured>) this.queryList(
                "queryFacadeAppInsuredByMap", map);
    }
    
    /**
     * 删除被保险人
     * @param appNo
     * @throws Exception
     */
    @Override
    public void deleteInsuredByAppNo(String appNo) throws Exception {
        this.delete("deleteInsuredByAppNo", appNo);
    }
}
